<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .cls{
            width: 200px;
            height: 200px;           
        }

    </style>
</head>
<body>    
    <div id="app">       
        <book class="cls" style=" background-color: red;" @click="cancelFn"></book>
    </div>

    <script src="./js/vue.global.js"></script>

    <script>

        let book = {       
            template:`
                <div style="border:5px solid black" @click="clickFn">
                    <div>书籍组件</div>
                    <p>书名:{{name}}</p>
                    <p >作者:{{author}}</p>   
                </div>
            `,
            inheritAttrs: false,
            methods:{
                clickFn(){
                    console.log("子组件的clickFn");
                }
            }
        }
       
        let app = Vue.createApp({
            data(){
                return {
                    msg:"hello",
                    name:"三国演义",
                    str:"罗贯中"
                }
            },
            methods:{
                cancelFn(){
                    console.log("父组件的cancelFn");
                }
            }            
        });

        app.component("book",book);
      
        app.mount("#app");

    </script>
</body>
</html>